package cn.ekuma.epos.datalogic.define.dao;

import java.util.List;

import com.openbravo.bean.BomIncludeProductInfo;
import com.openbravo.data.basic.BasicException;
import com.openbravo.data.loader.serialize.DataRead;
import com.openbravo.data.loader.I_Session;
import com.openbravo.data.loader.sentence.PreparedSentence;
import com.openbravo.data.loader.serialize.serializer.write.SerializerWriteString;

import e.odbo.data.dao.ViewDAO;

public class BomIncludeProductInfoDAO extends ViewDAO<BomIncludeProductInfo>{

	static String LIST_SQL="SELECT B.PARENT,B.REFID,B.UNITS,P.ISBOMSTORE FROM BOMS B  LEFT  JOIN PRODUCTS P ON B.REFID=P.ID WHERE B.PARENT=?";
	
	public BomIncludeProductInfoDAO(I_Session s) {
		super(s);
		
	}

	@Override
	public Class getSuportClass() {
		return BomIncludeProductInfo.class;
	}

	@Override
	public BomIncludeProductInfo readValues(DataRead dr,
			BomIncludeProductInfo obj) throws BasicException {
		if(obj==null)
			obj=new BomIncludeProductInfo();
		obj.setProductID(dr.getString(1));
		obj.setIncludeProduct(dr.getString(2));
		obj.setUnits(dr.getDouble(3));
		obj.setBomStore(dr.getBoolean(4));
		return obj;
	}

	public List<BomIncludeProductInfo> list(String productId) throws BasicException{
		return new PreparedSentence(s, LIST_SQL, SerializerWriteString.INSTANCE, this).list(productId);
	}
	
}
